package com.allen.study;

import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.openfeign.EnableFeignClients;
//import org.springframework.context.annotation.ComponentScan;

/**
 * 应用启动类
 *
 * @author AllenSun
 * @since 2025-03-15 21:29
 */
@SpringBootApplication
//@ComponentScan(value = {
//        // 必须：本项目扫描路径
//        "com.allen.study"
//})
// 这两个是springCloud的注解，暂时不用
//@EnableDiscoveryClient
//@EnableFeignClients
@Log4j2
public class AuthApplication {

    /**
     * 启动项
     *
     * @param args
     */
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(AuthApplication.class, args);
        Environment env = context.getEnvironment();

        // 获取端口号（默认值设置为空字符串避免空指针）
        String port = env.getProperty("server.port", "未配置端口");
        String contextPath = env.getProperty("server.servlet.context-path", "");

        // 打印启动信息
        System.out.println("\n=================================");
        System.out.println("应用启动成功！访问地址: http://localhost:" + port + contextPath);
        System.out.println("=================================");
    }
}
